package lancs.mobilemedia.core.ui.controller.commands;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.List;

import lancs.mobilemedia.core.ui.controller.AbstractController;
import lancs.mobilemedia.core.ui.controller.ControllerCommand;
import lancs.mobilemedia.core.ui.controller.ScreenSingleton;
import lancs.mobilemedia.core.util.Constants;

public class DeleteAlbum implements ControllerCommand {

	public boolean execute(AbstractController controller) {
		System.out.println("Delete Photo Album here");
		List down = (List) Display.getDisplay(controller.getMidlet()).getCurrent();
		ScreenSingleton.getInstance().setCurrentScreenName(Constants.CONFIRMDELETEALBUM_SCREEN);
		ScreenSingleton.getInstance().setCurrentStoreName(down.getString(down.getSelectedIndex()));
		String message = "Would you like to remove the album "+ScreenSingleton.getInstance().getCurrentStoreName();
		Alert deleteConfAlert = new Alert("Delete Photo Album", message,null,AlertType.CONFIRMATION);
		deleteConfAlert.setTimeout(Alert.FOREVER);
		deleteConfAlert.addCommand(new Command("Yes - Delete", Command.OK, 2));
		deleteConfAlert.addCommand(new Command("No - Delete", Command.CANCEL, 2));
		controller.setAlbumListAsCurrentScreen(deleteConfAlert);
		deleteConfAlert.setCommandListener(controller);
		return true;	
	}
}
